<%--
  Created by IntelliJ IDEA.
  User: 123
  Date: 2021/5/8
  Time: 22:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>登入界面</title>
    <link type="text/css" rel="stylesheet" href="../../Static-Resources/css/helloLogin.css" />
    <script type="text/javascript" src="../../Static-Resources/js/jquery-3.4.1.js"></script>

</head>
<body>
<div class="a">
    <div class="b"></div>
    <div class="c">
        <div class="d">
            <h1>用户登入</h1>
            <input type="text" class="e" placeholder="用户名" id="name" required>
            <input type="password" class="e" placeholder="电话" id="phone" required>
            <input type="password" class="e" placeholder="邮箱" id="email" required>
            <a href="${pageContext.request.contextPath}/registered" class="f">注册界面！</a>
            <a href="#" class="f" style="padding-right:20px">忘记用户名?</a>
            <input type="button" class="g" onclick="sub()" value="登入" />
        </div>
    </div>
</div>
<script type="text/javascript">
    function sub(){
        $.ajax({
            url : "${pageContext.request.contextPath}/check/login",
            data :{
                name : $('#name').val(),
                phone : $('#phone').val(),
                email : $('#email').val()
            },
            success : (data) =>{
                if (data){
                    $(window).attr('location',"${pageContext.request.contextPath}/article");
                }
                else{
                    alert('信息出错');
                }
            }
        })
    }
</script>
</body>
</html>
